/**
 * JSONUtils.java
 * Created at 2017-10-18
 * Created by zhanghailin
 * Copyright (C) 2017 BROADTEXT SOFTWARE, All rights reserved.
 */
package com.broadtext.common.utils;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

/**
 * <p>ClassName: JSONUtils</p>
 * <p>Description: TODO</p>
 * <p>Author: zhanghailin</p>
 * <p>Date: 2017-10-18</p>
 */
public class JSONUtils {
    
    public static Map<String,Object> param2Map(String param){
        Map<String,Object> map = new HashMap<String, Object>();
        JSONArray array = JSON.parseArray(param);
        if(array != null) {
            Iterator<Object> it;
            it = array.iterator();
            while (it.hasNext()) {
                JSONObject obj;
                obj = (JSONObject) it.next();
                if (obj.get("value") != null && StringUtils.isNotBlank(obj.get("value")+"")) {
                    map.put(obj.get("name") + "", obj.get("value"));
                }
            }
        }
        return map;
        
    }

}
